<?php

namespace App\Services\UserInviteInfo;

use App\Models\User;
use App\Models\Product;

class MakeUserInviteString
{
	/**
	 * @var User
	 */
	protected $user;
	
	/**
	 * @var null | Product
	 */
	protected $product = null;
	
	protected $channel = 'wap'; // wap, app, mini
	
	public function __construct(User $user, Product $product = null, $channel = 'wap')
	{
		$this->user = $user;
		$this->product = $product;
		$this->channel = $channel;
	}
	
	public function inviteString()
	{
		$args = [
			'inviter_id' => $this->user->id,
			'inviter_code' => $this->user->invite_code,
			'is_share' => true
		];
		
		if ($this->product) {
			$args['product_id'] = $this->product->id;
		}
		
		return $args;
	}
	
	public function make()
	{
		if ($this->channel === 'wap') {
			return $this->inviteString();
		}
		return null;
	}
}
